import type { IActivityHandler } from "@vertigis/workflow"; /** An interface that defines the inputs of the activity. */ interface GetvGISDetailsInputs { /** * @displayName Assignee Email * @description The email of the assignee. * @required */ assigneeEmail: string; /** * @displayName Creator Email * @description The email of the creator. * @required */ creatorEmail: string; /** * @displayName Due Date * @description The due date for the task. * @required */ dueDate: string; /** * @displayName Polygon * @description The polygon coordinates. * @required */ polygon: string; /** * @displayName Name * @description The name of the task. * @required */ name: string; /** * @displayName Bearer Token * @description The bearer token for authorization. * @required */ bearerToken: string; /** * @displayName file * @description The bearer token for authorization. */ file: Blob; } /** An interface that defines the outputs of the activity. */ interface GetvGISDetailsOutputs { /** * @description The result of the activity. */ result: object; } /** * @displayName Get vGIS Details * @category Geocortex * @description Get vGIS Details v1.1 */ export default class GetvGISDetailsActivity implements IActivityHandler { /** Perform the execution logic of the activity. */ async execute(inputs: GetvGISDetailsInputs): Promise { try { const myHeaders = new Headers(); myHeaders.append("Authorization", `Bearer ${inputs.bearerToken}`); const formdata = new FormData(); formdata.append("assigneeEmail", inputs.assigneeEmail); formdata.append("creatorEmail", inputs.creatorEmail); formdata.append("dueDate", inputs.dueDate); formdata.append("polygon", inputs.polygon); formdata.append("name", inputs.name); if (inputs.file) { formdata.append("file", inputs.file, "file"); } const requestOptions = { method: "POST", headers: myHeaders, body: formdata, redirect: "follow" as RequestRedirect, }; const response = await fetch("https://external-api-vgis.meemim.com/api/custom/59307/dig-permit", requestOptions); const resultText = await response.json(); return { result: resultText, }; } catch (error) { console.error("Error in fetching data from vGIS") return { result: { IssueUrl: null, ViewpointUrl: null, QrCodeUrl: null, }, }; } } }